package com.itc.service.impl;

import com.codingapi.tx.annotation.TxTransaction;
import com.itc.client.Demo2Client;
import com.itc.dao.TestMapper;
import com.itc.entity.Client;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.itc.service.TestService;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.client.RestTemplate;

import java.util.List;

/**
 * @Auther: wangyanwei
 * @Date: 2018/8/17 09:12
 * @Description:
 */
@Service
public class TestServiceImpl implements TestService {

    @Autowired
    private TestMapper testMapper;

    @Autowired
    private Demo2Client demo2Client;


    @Autowired
    private RestTemplate restTemplate;

    @Override
    public List<Client> getClientAll() {
        return testMapper.getClientAll();
    }

    @Override
    @Transactional
    @TxTransaction(isStart = true)
    public int save(String name) {

        testMapper.save(name);
        //restTemplate.getForObject("http://client-server/client/save",String.class);
        demo2Client.save();

        int a=1/0;
        return 1;
    }
}
